package pers.wensheng.patterns.creator_pattern.factory_pattern.factory_method_pattern;

import pers.wensheng.patterns.creator_pattern.factory_pattern.factory_method_pattern.entity.Coffee;
import pers.wensheng.patterns.creator_pattern.factory_pattern.factory_method_pattern.factory.AmericanCoffeeFactory;
import pers.wensheng.patterns.creator_pattern.factory_pattern.factory_method_pattern.factory.LatteCoffeeFactory;

/**
 *  工厂方法模式
 *  符合开闭原则
 *  核心就是依赖抽象，充分利用多态
 *
 *  缺点：每增加一个产品就要增加一个具体产品类和一个对应的具体工厂类，这增加了系统的复杂度。
 */
public class Main {
    public static void main(String[] args) {
        CoffeeStore store = new CoffeeStore(new AmericanCoffeeFactory());
        Coffee coffee = store.orderCoffee();
        System.out.println(coffee.getName());

        CoffeeStore store1 = new CoffeeStore(new LatteCoffeeFactory());
        Coffee coffee1 = store1.orderCoffee();
        System.out.println(coffee1.getName());


    }
}
